#include<iostream>
#include<unistd.h>
#include<pthread.h>

using namespace std;

void *pthread_handl(void *arg){

     int cnt = 5;
	 while(cnt--)
	 {
		cout << "我是新线程"  << endl;
		sleep(1);
	}
     
     pthread_exit((void*)1234);
}

int main(){

    pthread_t tid;
    pthread_create(&tid, nullptr, pthread_handl, nullptr);
				
	void* retval;
    sleep(3);
    pthread_cancel(tid);
	pthread_join(tid, &retval);
				
	cout << "进程退出,子线程退出码为：retval = " << (long long)retval << endl;

    return 0;
}